package com.samphanie.dries.validation;

import com.samphanie.dries.annotation.PasswordMatch;
import com.samphanie.dries.domain.dto.UserDto;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @Description:
 * @Author ZSY
 * @createTime 2021/2/25 15:35
 */
public class PasswordMatchValidator implements ConstraintValidator<PasswordMatch, UserDto> {
    @Override
    public void initialize(PasswordMatch constraintAnnotation) {

    }

    @Override
    public boolean isValid(UserDto userDto, ConstraintValidatorContext context) {
        return userDto.getPassword().equals(userDto.getMatchPassword());
    }
}
